home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 6.0 KB | 191 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWButton.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFrameW.hpp"
-
- #ifndef FWBUTTON_H
- #include "FWButton.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- // ----- Framewrk Includes -----
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgadgts
- #endif
-
- FW_DEFINE_CLASS_M2(FW_CButton, FW_CGadget, FW_MNotifier)
- FW_REGISTER_ARCHIVABLE_CLASS(FW_LButton, FW_CButton, FW_CButton::Read, FW_CGadget::Write)
-
- //========================================================================================
- // CLASS FW_CButtonPressedNotification
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CButtonPressedNotification::FW_CButtonPressedNotification
- //----------------------------------------------------------------------------------------
-
- FW_CButtonPressedNotification::FW_CButtonPressedNotification(const FW_CInterest& interest,
- ODID buttonId, short buttonState) :
- FW_CNotification(interest),
- fButtonId(buttonId),
- fButtonState(buttonState)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CButtonPressedNotification::FW_CButtonPressedNotification
- //----------------------------------------------------------------------------------------
-
- FW_CButtonPressedNotification::FW_CButtonPressedNotification(const FW_CButtonPressedNotification& other) :
- FW_CNotification(other),
- fButtonId(other.fButtonId),
- fButtonState(other.fButtonState)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CButtonPressedNotification::~FW_CButtonPressedNotification
- //----------------------------------------------------------------------------------------
-
- FW_CButtonPressedNotification::~FW_CButtonPressedNotification()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CButtonPressedNotification::operator==
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CButtonPressedNotification::operator==
- (const FW_CButtonPressedNotification& other)
- {
- return FW_CNotification::operator==(other) &&
- fButtonId == other.fButtonId &&
- fButtonState == other.fButtonState;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CButtonPressedNotification::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CButtonPressedNotification& FW_CButtonPressedNotification::operator=
- (const FW_CButtonPressedNotification& other)
- {
- if (this == &other)
- return *this;
-
- FW_CNotification::operator=(other);
- fButtonId = other.fButtonId;
- fButtonState = other.fButtonState;
-
- return *this;
- }
-
- //========================================================================================
- // CLASS FW_CButton
- //========================================================================================
-
- const ODType FW_CButton::kButtonPressedNotification = "FW_CButton:ButtonPressedNotification";
-
- //----------------------------------------------------------------------------------------
- // FW_CButton::FW_CButton
- //----------------------------------------------------------------------------------------
-
- FW_CButton::FW_CButton(Environment* ev,
- FW_CView* container, ODID id,
- const FW_CRect& bounds) :
- FW_MNotifier(),
- FW_CGadget(ev, container, id, bounds),
- fButtonPressedNotificationToken(0)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CButton::InitializeButton
- //----------------------------------------------------------------------------------------
-
- FW_CButton::FW_CButton(Environment* ev, FW_CReadableStream& archive) :
- FW_MNotifier(),
- FW_CGadget(ev, archive),
- fButtonPressedNotificationToken(0)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CButton::~FW_CButton
- //----------------------------------------------------------------------------------------
-
- FW_CButton::~FW_CButton()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CButton::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CButton::Flatten(FW_CWritableStream& archive) const
- {
- FW_CGadget::Flatten(archive);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CButton::Read
- //----------------------------------------------------------------------------------------
-
- void* FW_CButton::Read(FW_CReadableStream& archive)
- {
- Environment* ev = ::somGetGlobalEnvironment();
- return new FW_CButton(ev, archive);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CButton::GetButtonPressedToken
- //----------------------------------------------------------------------------------------
-
- ODTypeToken FW_CButton::GetButtonPressedNotificationToken(Environment* ev) const
- {
- FW_CButton* self = (FW_CButton *) this;
-
- if (fButtonPressedNotificationToken == 0)
- {
- self->fButtonPressedNotificationToken
- = GetFrame(ev)->GetPart(ev)
- ->GetSession(ev)->Tokenize(ev, kButtonPressedNotification);
- }
-
- return fButtonPressedNotificationToken;
- }
-